Skip to content

Return retry status for Firstrade execution blocks#108

Merged
Pigbibi merged 1 commit into
mainfrom
feature/retryable-execution-block-status
Jun 19, 2026
Merged

Return retry status for Firstrade execution blocks#108
Pigbibi merged 1 commit into
mainfrom
feature/retryable-execution-block-status

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • return HTTP 500 for retryable Firstrade execution blocks so Cloud Scheduler can retry
  • keep terminal funding blocks at HTTP 200 so insufficient cash does not retry

Tests

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --no-project --with pytest --with requests --with google-auth --with flask --with pandas python -m pytest tests/test_request_handling.py::test_run_endpoint_returns_200_for_terminal_funding_block tests/test_request_handling.py::test_run_endpoint_returns_500_for_retryable_execution_block
  • python3 -m py_compile main.py

@Pigbibi Pigbibi merged commit 36c2e3e into main Jun 19, 2026
1 check passed
@Pigbibi Pigbibi deleted the feature/retryable-execution-block-status branch June 19, 2026 10:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86d59d5b3f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread main.py


def _strategy_result_http_status(result: dict[str, Any]) -> int:
if result.get("execution_blocked") and result.get("execution_block_retryable") and not result.get("funding_blocked"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Respect retryable funding blocks

When a cycle submits at least one order and then hits an insufficient-cash skip on a later buy, run_strategy_cycle can return both funding_blocked=True and execution_block_retryable=True: terminal funding is only funding_blocked and not action_done, while funding_blocked is still copied into the result. This extra not result.get("funding_blocked") therefore makes those partial-submitted retryable blocks return HTTP 200, so the /run Cloud Scheduler job will not retry even though the result explicitly marks the execution block as retryable.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant